var userAgent = window.navigator.userAgent.toLocaleLowerCase();
if (userAgent.indexOf('jjrb') > -1) {//在端内
}else{
  $('.j-banner').css('display','block');
  $('.main').css('margin-bottom','3.68rem');
  $('.footer').css('margin-bottom','1.333rem');
}

getVotedetail(function(resData){
  sessionStorage.setItem('detail','true');
  document.title = resData['title'];
  wxShare(resData['title'], '分享来自经济日报客户端，更多精彩请下载http://d.jingjiribao.cn/index.html',resData['shareImg'], resData['shareUrl']); 
  $('.j-detailtitle').html(resData.voteoptions);

  $('.j-detailcontent').html(resData.detail);  
  $('.j-detailcontent').find('img,video').parent('p').css('text-indent','0');
  $('.j-detailcontent').find('video').attr('controlsList','nofullscreen nodownload noremote footbar');
  $('.j-detailcontent').find('video').attr('x5-playsinline',true).attr('playsinline',true).attr('webkit-playsinline',true).attr('x5-video-player-type',"h5");
   // $('.j-detailcontent').html(formateContent(resData.detail));

  if(voteParams['status'] == '0'){
    $('.j-votebtn').text('暂未开始').addClass('forbidbtn');
  }else if(voteParams['status'] == '1'){
    if(voteParams['checked'] == 1){
      $('.j-votebtn').text('感谢支持').removeClass('j-votebtn').addClass('outbtn');
    }else{
      $('.j-votebtn').text('投TA一票');
    }
  }else if(voteParams['status'] == '2'){
   $('.j-votebtn').text('活动结束').addClass('forbidbtn');
  }

  $('.j-votebtn').click(function(){
    var _this = this;
    if(voteParams['status'] == '0'){
      toast.success('活动暂未开始',1500);
    }else if(voteParams['status'] == '1'){
      submitVote(voteParams['optionid'], voteParams['needlog'],function(res){
        toast.success(res.message,1500);
        if(res.data == false){//投票达到上限
          $(_this).text('感谢支持').removeClass('j-votebtn').addClass('outbtn');
        }
       

      });
    }else if(voteParams['status'] == '2'){
      toast.success('活动已结束',1500);
    }
  });

 

  function formateContent(content) {
    return content.replace(/(<a[^>]+href\s*=\s*""?(http[^>""\s]+)""?[^>]*>)/gi, '<a onclick="openNewWindow(\'$2\')" >')
            .replace(/(<video[^>]+class\s*=\s*"vr-video"?[^>]+src\s*=\s*""?([^>""\s]+)""?[^>]+poster\s*=\s*""?([^>""\s]+)""?[^>]*>)/gi, '<a onclick="playVr(\'$2\');" class="video-container"><img src="$3" onerror="videoImgErr(this)" data-url="$2" onload="showIcon(this)"><span class="player-icon"></span></a>')
            .replace(/(<video[^>]+src\s*=\s*""?([^>""\s]+)""?[^>]+poster\s*=\s*""?([^>""\s]+)""?[^>]*>)/gi, '<a onclick="playVideo(this, \'$2\',\'$3\');" class="video-container"><img src="$3" onerror="videoImgErr(this)" data-url="$2" onload="showIcon(this)"><span class="player-icon"></span></a>')
            .replace(/(<video[^>]+poster\s*=\s*""?([^>""\s]+)""?[^>]+src\s*=\s*""?([^>""\s]+)""?[^>]*>)/gi, '<a onclick="playVideo(this, \'$3\',\'$2\');" class="video-container"><img src="$2" onerror="videoImgErr(this)" data-url="$2" onload="showIcon(this)"><span class="player-icon"></span></a>');
  }

  function formateImage(content,type){
    if(type == 1){
      return content.replace(/(<img[^>]+src\s*=\s*""?([^>""\s]+)""?[^>])/gi, '<img src="../static/imgs/defalut-img.png" data-src="$2" class="3g-no-image"');
    }
    else {
      return content.replace(/(<img[^>]+src\s*=\s*""?([^>""\s]+)""?[^>])/gi, '<img src="$2" data-src="$2"');
    }
  }

 
  function videoImgErr(obj) {
    $(obj).parent().addClass("no-image");
    $(obj).next(".player-icon").show();
    $(obj).remove();
  }


});
